﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RookieGrow.Domain.Model.SportsStore;
using RookieGrow.Data.SportsStore;

namespace RookieGrow.Domain.SportsStore
{
    public class ShoppingCart
    {
        protected IValueCalculator calculator;
        protected IDataProvider<Product> productDataProvider;

        public ShoppingCart(IValueCalculator calculator, IDataProvider<Product> productDataProvider)
        {
            this.calculator = calculator;
            this.productDataProvider = productDataProvider;
        }

        public virtual decimal CalculateStockValue()
        {
            // define the set of products to sum
            List<Product> products = productDataProvider.GetList();

            // calculate the total value of the products
            decimal totalValue = calculator.ValueProducts(products);

            // return the result
            return totalValue;
        }
    }
}
